﻿<Window x:Class="RL.wVehicle"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Транспортное средство" Height="397" Width="996" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:my="clr-namespace:RL" Loaded="Window_Loaded" Closing="Window_Closing">
    <Window.Resources>
        <CollectionViewSource x:Key="vehicleViewSource" d:DesignSource="{d:DesignInstance my:vehicle, CreateList=True}" />
        <CollectionViewSource x:Key="vehicleTypeViewSource" />
    </Window.Resources>
    <Grid DataContext="{StaticResource vehicleViewSource}">
        <Grid.RowDefinitions>
            <RowDefinition  Height="35"/>
            <RowDefinition />
            <RowDefinition  Height="35"/>
        </Grid.RowDefinitions>
        <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding}" Name="vehicleDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" Grid.Row="1" CanUserAddRows="False" CanUserDeleteRows="False">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="idColumn" Binding="{Binding Path=id}" Header="код" Width="50" />
                <DataGridTemplateColumn x:Name="id_typeColumn" Header="Модель" Width="200">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <!-- <ComboBox SelectedItem="{Binding Path=vehicle_type, Mode=TwoWay}" DisplayMemberPath="name" ItemsSource="{Binding Source={StaticResource vehicleTypeViewSource}}" IsSynchronizedWithCurrentItem="False"> -->
                            <ComboBox SelectedValuePath="id" SelectedValue="{Binding Path=id_type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" DisplayMemberPath="name" ItemsSource="{Binding Source={StaticResource vehicleTypeViewSource}}" IsSynchronizedWithCurrentItem="False">
                                <!--<ComboBoxItem Content="{Binding Path=id_type}" /> -->
                            </ComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=vehicle_type.name}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn x:Name="gar_numberColumn" Binding="{Binding Path=gar_number}" Header="гаражный номер" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="gos_numberColumn" Binding="{Binding Path=gos_number}" Header="государственный номер" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="license_reg_numberColumn" Binding="{Binding Path=license_reg_number}" Header="номер лицензии" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="license_reg_serialColumn" Binding="{Binding Path=license_reg_serial}" Header="серия лицензии" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="license_numberColumn" Binding="{Binding Path=license_number}" Header="лицензия" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="qntPassColumn" Binding="{Binding Path=qnt_passenger}" Header="пасс. мест" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="tqntPassColumn" Binding="{Binding Path=qnt_total_passenger}" Header="всего. пасс." Width="SizeToHeader" />
                <DataGridCheckBoxColumn x:Name="delColumn" Binding="{Binding Path=del}" Header="выкл." Width="SizeToHeader" IsReadOnly="True"/>
            </DataGrid.Columns>
        </DataGrid>
        <StackPanel Name="stackPanel1" Orientation="Horizontal">
            <Button Content="Сохранить" Height="23" Name="buttonSave" Width="75" Click="buttonSave_Click"/>
            <Button Content="Добавить" Height="23" Name="buttonAdd" Width="75" Click="buttonAdd_Click"/>
        </StackPanel>
        <StackPanel Grid.Row="2" Name="stackPanel2" Orientation="Horizontal">
            <Button Content="OK" Height="23" Name="buttonOK" Width="75" Click="buttonOK_Click"/>
        </StackPanel>
    </Grid>
</Window>
